package com.hsd.voice_asr.socket;

import com.hsd.voice_asr.properties.AliAsrProperties;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class TCPStreamServer extends Thread {

    public volatile boolean flag = true;

    private AliAsrProperties aliAsrProperties;

    public TCPStreamServer(AliAsrProperties aliAsrProperties) {
        this.aliAsrProperties = aliAsrProperties;
    }

    public void run() {
        try {
            ServerSocket serverSocket = new ServerSocket(9998);
            Socket socket;
            while (flag) {
                socket = serverSocket.accept();
                SocketStreamThread serverThread = new SocketStreamThread(socket,aliAsrProperties);
                serverThread.start();
            }
            serverSocket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
